import { IFeidaoAiMobile } from '@dfeidao/atom-mobile/interfaces';
import React, { BaseSyntheticEvent } from 'react';
import { Button, FlatList, Text, View } from 'react-native';
import a003 from './a003';
import a004 from './a004';

export default function tpl(a: <T>(action: string) => ((ev: BaseSyntheticEvent<T>) => void), s: (...class_name: string[]) => {}, d: (d: string) => string | unknown[]) {
	return (<View>
		<Text>首页</Text>
		<Button title='+' onPress={a('a001')}></Button>
		<FlatList
			data={d('arr')} renderItem={renderMovie} style={s('list')} keyExtractor={(_item, i) => i.toString()} />

	</View >);
	interface Iarr {
		item: {
			id: number;
			text: string;
			show: boolean;
		};
	}
	function renderMovie({ item }: Iarr) {
		if (item.show) {
			return (
				<View style={s('container')}>
					<View style={s('rightContainer')}>
						<Text style={s('title')} onPress={() => {
							a003((d('fd') as unknown) as IFeidaoAiMobile, item);
						}}>{item.text}</Text>
						<View >
							<Text style={s('you')} onPress={() => {
								a004((d('fd') as unknown) as IFeidaoAiMobile, item);
							}}>删除</Text>
						</View>
					</View>
				</View>
			);
		} else {
			return (
				<View style={s('container')}>
					<View style={s('rightContainer')}>
						<Text style={s('title')} onPress={() => {
							a003((d('fd') as unknown) as IFeidaoAiMobile, item);
						}}>{item.text}</Text>
					</View>
				</View>
			);
		}
	}
}
